// defineStore定义小仓库，两个参数，第一个参数是id或options，第二个参数是setup函数或options对象。
import { defineStore } from 'pinia';
import { reqHospitalDetail,reqHospitalDepartment } from '@/api/hospital/index.js'

//pinia仓库写法：组合式API、选择式API、类式API
export const useDetailStore = defineStore('Detail', {
    state: () => {
        return {
            hospitalDetail: {},
            departmentList: []
        }
    },
    getters: {},
    actions: {
    // 获取医院详情数据
        async getHospitalDetail(hoscode) {
            const {code, data} = await reqHospitalDetail(hoscode)
            if (code === 200) {
                this.hospitalDetail = data;
            }
        },
    //  获取医院科室列表数据
        async getHospitalDepartment(hoscode) {
            const { code, data } = await reqHospitalDepartment(hoscode)
            if (code === 200) {
                this.departmentList = data;
            }
        }
    },
})

